package cn.com.cabinet.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cabinet.web.entity.Cabinet;

import cn.com.cabinet.dao.CabinetDao;

@Service
public class CabinetServiceImpl {
	
	@Autowired
	private CabinetDao cabinetDao;
	
	/**
	 * 通过柜子类型获取未出租并允许出租的柜子
	 * @return
	 */
	public List<Cabinet> getCabinetByNoneMark(String cClass,Integer page,Integer limit){
		return cabinetDao.getCabinetByNoneMark(cClass, page, limit);
		
	}
	
	
	public int getCabinetCountByNoneMark(String cClass){
		return cabinetDao.getCabinetCountByNoneMark(cClass);
	}

	
	public List<Cabinet> getCabinetBySellerId(Long sellerId,String cClass,Integer page,Integer limit){
		
		if(cClass == null || cClass.equals("") || cClass.equals("null")){
			System.out.println("cClass is null");
			return cabinetDao.getCabinetBySellerid(sellerId, page, limit);
		}else{
			return cabinetDao.getCabinetBySellerid(sellerId, cClass, page, limit);
		}		
	}
	
	
	public int getCabinetCountBySellerId(Long sellerId,String cClass){
		if(cClass == null || cClass.equals("") || cClass.equals("null")){
			System.out.println("cClass is count null");
			return cabinetDao.getCabinetCountBySellerid(sellerId);
		}else{
			System.out.println("cClass is count");
			return cabinetDao.getCabinetCountBySellerid(sellerId, cClass);
		}
	}
	

}
